if (!requireNamespace("librarian", quietly =TRUE)) {# If not installed, install the packageinstall.packages("librarian")}librarian::shelf( dplyr, here, htmltools, reactablefmtr, tidyverse)
df <- data %>%select( Dataset.title, Technical.POC.email., doi, erddap, erddap_link, obis, obis_link, ncei, ncei_link, web, web_link, code, code_link)df %>%reactable(theme =pff(centered =TRUE),defaultColDef =colDef(footerStyle =list(fontWeight ="bold")),columns =list(Dataset.title =colDef(minWidth =175,footer ='Total',cell =merge_column(data = .,merged_name ='Technical.POC.email.',merged_position ='below',merged_size =14,size =16,color ='#333333',spacing =-1 ) ),Technical.POC.email. =colDef(show =FALSE),doi =colDef(cell =function(value, index) {# Check if the link is NA or NULL url <- valueif (is.na(url) ||is.null(url) ||trimws(url) =="") {return("No") } else {# Return clickable link if URL is availablesprintf('<a href="https://doi.org/%s" target="_blank">Yes</a>', value) } },html =TRUE# Enable HTML rendering in the cell ),erddap =colDef(cell =function(value, index) {# Check if the link is NA or NULL url <- df$erddap_link[index]if (is.na(url) ||is.null(url) ||trimws(url) =="") {return(value) # Just return the original text if no link is available } else {# Return clickable link if URL is availablesprintf('<a href="%s" target="_blank">%s</a>', url, value) } },html =TRUE# Enable HTML rendering in the cell ),erddap_link =colDef(show =FALSE),obis =colDef(cell =function(value, index) {# Check if the link is NA or NULL url <- df$obis_link[index]if (is.na(url) ||is.null(url) ||trimws(url) =="") {return(value) # Just return the original text if no link is available } else {# Return clickable link if URL is availablesprintf('<a href="%s" target="_blank">%s</a>', url, value) } },html =TRUE# Enable HTML rendering in the cell ),obis_link =colDef(show =FALSE),ncei =colDef(cell =function(value, index) {# Check if the link is NA or NULL url <- df$ncei_link[index]if (is.na(url) ||is.null(url) ||trimws(url) =="") {return(value) # Just return the original text if no link is available } else {# Return clickable link if URL is availablesprintf('<a href="%s" target="_blank">%s</a>', url, value) } },html =TRUE# Enable HTML rendering in the cell ),ncei_link =colDef(show =FALSE),web =colDef(cell =function(value, index) {# Check if the link is NA or NULL url <- df$web_link[index]if (is.na(url) ||is.null(url) ||trimws(url) =="") {return(value) # Just return the original text if no link is available } else {# Return clickable link if URL is availablesprintf('<a href="%s" target="_blank">%s</a>', url, value) } },html =TRUE# Enable HTML rendering in the cell ),web_link =colDef(show =FALSE),code =colDef(cell =function(value, index) {# Check if the link is NA or NULL url <- df$code_link[index]if (is.na(url) ||is.null(url) ||trimws(url) =="") {return(value) # Just return the original text if no link is available } else {# Return clickable link if URL is availablesprintf('<a href="%s" target="_blank">%s</a>', url, value) } },html =TRUE# Enable HTML rendering in the cell ),code_link =colDef(show =FALSE) ) ) %>%add_title(title ='Dataset Publication Summary' )